﻿using System;
using System.Collections.Generic;
 
using System.Text;
using PanGu;

namespace MOLE
{
    public class pinyinConvertX
    {
        private static PanGu.Match.MatchOptions _Options;
        private  static PanGu.Match.MatchParameter _Parameters;
        // 2012.7.8 ati 
        public static string Convert(string source)
        {
            PanGu.Segment.Init();
            _Options = PanGu.Setting.PanGuSettings.Config.MatchOptions.Clone();
            _Parameters = PanGu.Setting.PanGuSettings.Config.Parameters.Clone();
            Segment segment = new Segment();
            ICollection<WordInfo> words = segment.DoSegment(source, _Options, _Parameters);


            StringBuilder wordsString = new StringBuilder();
            foreach (WordInfo wordInfo in words)
            {
                if (wordInfo == null)
                {
                    continue;
                }

                if (showPosition)
                {

                    wordsString.AppendFormat("{0}({1},{2})/", wordInfo.Word, wordInfo.Position, wordInfo.Rank);
                    //if (_Options.MultiDimensionality)
                    //{
                    //}
                    //else
                    //{
                    //    wordsString.AppendFormat("{0}({1})/", wordInfo.Word, wordInfo.Position);
                    //}
                }
                else
                {
                    wordsString.AppendFormat("{0} ", wordInfo.Word);     //ati
                }
            }

          string  tar =wordsString.ToString(); 
            tar=MOLE.meadsi.Hz2Py.Convert(tar);
            return tar;

        }


        public static bool showPosition { get; set; }
    }
          
}
